/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ejb.warehouse;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author ciummo
 */
@Stateless
public class ProdottoFacade extends AbstractFacade<Prodotto> implements ProdottoFacadeRemote {
    @PersistenceContext(unitName = "DGestEJBSeverPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public ProdottoFacade() {
        super(Prodotto.class);
    }
    
        public List<Prodotto> findProdottiByIdOrdineProdotto (int idOrderProduct){

        String sql = "SELECT p FROM Prodotto p WHERE p.idOrdineProdotto = :idOrdineProdotto";
        Query query = em.createQuery(sql);
        query.setParameter("idOrdineProdotto", idOrderProduct);
        return query.getResultList();
    }
    
}
